İyonik uygulamanın kullanımı için bir api yapmak istiyorum (arka uç için laravel 4.2 kullanıyorum). örneğin :İki tablodan (kullanıcılar ve yazılar) iyonik için bir api nasıl yapılır
$tourists = User::where('block','0')
->where('guider', 1)
->where('location', $location)
->orderBy($orderBy, 'desc')
->orderBy('updated_at', 'desc')
->get();
return View::make('frontend.data.touristsData',array('tourists'=>$tourists));
// touristsData:
// my app.js kullanmış<?php
echo json_encode($tourists);
(iyonik):
// aşağıdaki $ turist yapılmış
.controller('listController', ['$scope','$http','$state','$ionicModal', function($scope, $http, $state,$ionicModal){
$http.get("./touristsData").success(
function(data){
$scope.tourists = data;
......
// html
<div>{{tourists.username}}: {{tourists.intro}}</div>
// yukarıdaki bir masanın
ama ne ben, örneğin iki tablo varsa içindir, kullanıcılar masa ve mesajlar tablo
// kullanıcıların tablo (laravel göç)
$table -> increments('id');//id auto_increment
$table -> string('username',30);
$table -> string('email',60) -> unique();
$table -> string('password',64);
$table -> boolean('admin')->default(0);
$table -> boolean('block')->default(0);
$table -> integer('tradeTime');
$table -> string('nationality', 50);
// mesajlar tablo
$table->increments('id');
$table -> integer('needHour');
$table -> string('travelDestination',40);
$table -> text('intro',300);
$table -> string('otherWords', 100);
$table->integer('user_id');
$table->softDeletes();
$table ->timestamps();
//user.php
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
protected $guard = array('email', 'password');
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
public function posts(){
return $this->hasMany('Posts');
}
//post.php
<?php
use Illuminate\Database\Eloquent\SoftDeletingTrait;
class post extends Eloquent{
use SoftDeletingTrait;
protected $dates = ['deleted_at'];
protected $fillable = ['needHour', 'travelDestination','intro','otherWords'];
public function user()
{
return $this->belongsTo('User');
}
}
kullanıcıların masa ve mesajlar tablo user_id birbirine bağlantılı olduğunu görebilirsiniz
, yüzden benim sorum nasıl yapabiliriz çıktı iki içerikleri Tablo kombine, sadece yukarıdaki gibi, sadece bir tablo çıktı (bu kolay)?
ne ben achevie istiyorum aşağıdaki kodla gibidir:
<div>{{tourists.username}} : {{tourists.travelDestination}}</div>
Modeller ve tablolar için bir isim kuralına uymalısınız. Tablo adınız yayınlar ve modeli 'İhtiyaç'. Modellerin isimlerini göremiyorum. İkisi de aynı isim alanında mı? – ggderas
üzgünüm, sadece değiştirdim – franklee