Theo mặc định, chúng tôi thường tìm kiếm bất kỳ mục nhập nào trên bảng db theo số id. Nhưng tôi không thể tìm thấy cách tìm kiếm bất kỳ mục nhập nào bằng tên cột.Làm thế nào để tìm mục nhập bằng tên trong Laro hùng hồn?
Đây là mã của tôi cho việc tìm kiếm nhập cảnh và làm cho nó để xem
Bộ điều khiển: Tác giả
class Authors_Controller extends Base_Controller {
public $restful = true;
public function get_view($id){
$authorModel = Authors::find($id);
return View::make('authors.view')
->with('author', $authorModel)
->with('title', $authorModel->name);
}
}
mẫu: Tác giả
<?php
class Authors extends Eloquent {
public static $table = 'authors';
}
Route:
Route::controller(Controller::detect());
Route::get('author/(:any)', array('as'=>'author', 'uses'=>'[email protected]'));
Xem:
@layout('main.index')
@section('content')
<h1>{{$author->name}}</h1>
<p>
{{$author->bio}}
</p>
<small>
{{$author->created_at}} |
{{HTML::link(URL::$base.'/authors/', 'Go back')}}
</small>
@endsection
Làm thế nào để tôi làm cho đường dẫn url là không hiển thị id nhưng để hiển thị tên của bài như
some.com/category/name (thay vì some.com/ loại/id)
Cảm ơn bạn đã giúp rất nhiều – monk
thật không may là không hoạt động – monk
không gian giữa hai từ có quan trọng không? – monk