laravel-eloquent

How to solve Missing argument 1 for App\Repositories\FavoriteRepository::delete() ? (Laravel 5.3)

爷,独闯天下 提交于 2019-11-27 04:55:26
问题 My service is like this : public function delete($store_id) { $result = $this->favorite_repository->delete($store_id); dd($result); } My repository is like this : public function delete($store_id) { $data = self::where('favoritable_id', $store_id)->delete(); return $data; } There exist error : Missing argument 1 for App\Repositories\FavoriteRepository::delete(), called in C:\xampp\htdocs\mysystem\app\Repositories\FavoriteRepository.php on line 45 and defined Can you help me? UPDATE The delete

Laravel Eloquent: multiple foreign keys for relationship

◇◆丶佛笑我妖孽 提交于 2019-11-26 23:28:04
问题 I am in the process of porting a project to Laravel. I have two database tables which are in a One-To-Many relationship with each other. They are joined by three conditions. How do I model this relationship in Eloquent? I am not supposed to modify the database schema, since it has to remain backwards compatible with other things. I have tried the following, but it doesn't work. The owning side: use Illuminate\Database\Eloquent\Model; class Route extends Model { public function trips() {

How can I solve incompatible with sql_mode=only_full_group_by in laravel eloquent?

落花浮王杯 提交于 2019-11-26 23:20:17
问题 My laravel eloquent is like this : $products = Product::where('status', 1) ->where('stock', '>', 0) ->where('category_id', '=', $category_id) ->groupBy('store_id') ->orderBy('updated_at', 'desc') ->take(4) ->get(); When executed, there exist error like this : SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'myshop.products.id' which is not functionally dependent on columns in GROUP BY clause; this

Property [title] does not exist on this collection instance

杀马特。学长 韩版系。学妹 提交于 2019-11-26 03:20:56
问题 I am following Laracasts\' videos: Basic Model/Controller/View Workflow. I have a table holds contact information. CREATE TABLE `about` ( `id` int(10) UNSIGNED NOT NULL, `title` varchar(500) COLLATE utf8_unicode_ci NOT NULL, `content` text COLLATE utf8_unicode_ci, ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci I am trying to pass data to view using the following code in the controller file: public function index() { $about = Page::where(\'page\', \'about-me\')->get(); //id = 3

Property [title] does not exist on this collection instance

社会主义新天地 提交于 2019-11-25 22:02:06
I am following Laracasts' videos: Basic Model/Controller/View Workflow . I have a table holds contact information. CREATE TABLE `about` ( `id` int(10) UNSIGNED NOT NULL, `title` varchar(500) COLLATE utf8_unicode_ci NOT NULL, `content` text COLLATE utf8_unicode_ci, ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci I am trying to pass data to view using the following code in the controller file: public function index() { $about = Page::where('page', 'about-me')->get(); //id = 3 return view('about', compact('about')); } When I try to show the code as shown below, @section('title') {{