Created
January 25, 2016 15:29
-
-
Save matgargano/62c91eefffb71d3ae154 to your computer and use it in GitHub Desktop.
Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.app') | |
@section('content') | |
@foreach($models as $model) | |
{{ $model->key }} | |
@endforeach | |
{!! Form::open((array('action' => 'ProfilesController@store'))) !!} | |
<input type="text" value=""> | |
<input type="submit" value="Submit"> | |
{!! Form::close() !!} | |
@stop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SundaySim\Http\Controllers; | |
use Illuminate\Http\Request; | |
use SundaySim\Http\Requests; | |
use SundaySim\UserMeta; | |
class ProfilesController extends Controller { | |
public function index( Request $auth ) { | |
$id = $auth->user()->id; | |
$models = UserMeta::where( 'user_id', $id )->get(); | |
return view( 'profile.main' )->with( 'models', [ 'models' => $model ] ); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SundaySim; | |
use Illuminate\Database\Eloquent\Model; | |
class UserMeta extends Model | |
{ | |
protected $fillable = [ | |
'key', 'value', 'user_id', | |
]; | |
public function user_id() { | |
return $this->belongsToMany('App\User', 'user_id', 'id'); // user_id on this model is a foreign key to id on app/user | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment