Created
November 23, 2015 16:32
-
-
Save insign/5ea274fa7321252b1292 to your computer and use it in GitHub Desktop.
Problemas com relacionamentos - laravel
This file contains 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
<div class="col-md-12"> | |
<a href="{!! action('CandidatoController@candidato', isset($pessoa->user_id) ? $pessoa->user_id : $pessoa->id) !!}"> | |
<img src="{!! App\User::primeira_foto($pessoa->id) !!}" class="img-rounded img-responsive" alt=""/> | |
</a> | |
</div> |
This file contains 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
<div class="col-md-12"> | |
<a href="{!! action('CandidatoController@candidato', isset($pessoa->user_id) ? $pessoa->user_id : $pessoa->id) !!}"> | |
<img src="{!! App\User::primeira_foto($pessoa->id) !!}" class="img-rounded img-responsive" alt=""/> | |
</a> | |
</div> |
This file contains 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 | |
// APENAS A PARTE RELEVANTE | |
public function fotos() | |
{ | |
return $this->hasMany('\App\UserFoto'); | |
} | |
?> |
This file contains 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 App; | |
use ___; | |
use Illuminate\Database\Eloquent\Model; | |
class UserFoto extends Model | |
{ | |
protected $fillable = []; | |
protected $table = 'users_fotos'; | |
protected $touches = ['user']; | |
public function user() | |
{ | |
return $this->belongsTo('\App\User'); | |
} | |
public function src() | |
{ | |
return ___::cdn_asset("{$this->user_id}/{$this->nome}"); | |
} | |
public function mini() | |
{ | |
return ___::cdn_asset("{$this->user_id}/mini/{$this->nome}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment