/** * Register any application services. * * @return void */ public function register() { $this->app->singleton('App\\Contracts\\Storages\\CategoryStorageContract', function () { return new CategoryStorage(Category::query()); }); $this->app->singleton('App\\Contracts\\Storages\\ItemStorageContract', function () { return new ItemStorage(Item::query()); }); $this->app->singleton('App\\Contracts\\Storages\\UserStorageContract', function () { return new UserStorageProxy(new UserStorage(User::query())); }); }
public function search($input) { $query = Category::query(); $columns = Schema::getColumnListing('$TABLE_NAME$'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute])) { $query->where($attribute, $input[$attribute]); } } return $query->get(); }
public function search($input) { $query = Category::query(); $columns = Schema::getColumnListing('categories'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }
/** * Removes the category. * @param $id * * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function destroy($id) { $this->category->query()->findOrFail($id)->delete(); return redirect()->route('category.index'); }