本文整理汇总了PHP中app\models\Category::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::destroy方法的具体用法?PHP Category::destroy怎么用?PHP Category::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Category
的用法示例。
在下文中一共展示了Category::destroy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCategories
public function postCategories(Request $request)
{
if ($request->has('adds')) {
$adds = $request->adds;
for ($i = 0; $i < count($adds); $i++) {
if ($adds[$i]['parent_id'] == 'null') {
Category::create(['title' => $adds[$i]['title']]);
} else {
$parent = Category::find($adds[$i]['parent_id']);
$child = $parent->children()->create(['title' => $adds[$i]['title'], 'slug' => str_slug($adds[$i]['title'])]);
for ($j = 0; $j < count($adds); $j++) {
if ($adds[$j]['parent_id'] == $adds[$i]['id']) {
$adds[$j]['parent_id'] = $child->id;
}
}
}
}
}
if ($request->has('updates')) {
$updates = $request->updates;
for ($i = 0; $i < count($updates); $i++) {
$category = Category::find($updates[$i]['id']);
$category->update(['title' => $updates[$i]['title'], 'slug' => str_slug($updates[$i]['title'])]);
}
}
if ($request->has('deletes')) {
$deletes = $request->deletes;
for ($i = 0; $i < count($deletes); $i++) {
Category::destroy($deletes[$i]);
}
}
}
示例2: destroy
public function destroy($id)
{
Cache::forget('admin_category_categories_wfh');
Cache::forget('wechat_index_categories_wfh');
Category::destroy($id);
return back();
}
示例3: delete
/**
* delete data
* @return json
*/
public function delete()
{
$id = (int) $_POST['id'];
$info = DB::select('select * from it_categories where parent_id = ?', [$id]);
if ($info) {
return response()->json(['status' => 100, 'message' => 'This category has child category cannot be deleted~~ ']);
}
$rs = Category::destroy($id);
if ($rs) {
return response()->json(['status' => 200, 'message' => 'Deleted Successfully~~']);
} else {
return response()->json(['status' => 400, 'message' => 'Delete Failure~~']);
}
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Category::destroy([$id]);
return redirect('category');
}
示例5: destroy
/**
* Remove the specified category from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Category::destroy($id);
return Redirect::route('categories.index');
}
示例6: delete
public function delete($categoryID)
{
Category::destroy($categoryID);
header("Location: " . base . "/Category");
}
示例7: destroy
public function destroy($id)
{
Cache::forget('wyshop_admin_category_categories');
Category::destroy($id);
return back()->with('info', '删除分类成功');
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if ($result = check_auth_to('FLGL_DELETE')) {
return $result;
}
try {
$count = Category::where('parent_id', '=', $id)->count();
if ($count !== 0) {
throw new \Exception("请先删除下级分类");
}
Category::destroy($id);
return redirect()->action('Admin\\CategoryController@index')->with('operationstatus', 'sucess');
} catch (\Exception $e) {
return redirect()->back()->withErrors(['error' => '删除文章分类失败,请重试(' . $e->getMessage() . ')']);
}
}
示例9: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
Category::destroy($id);
Session::flash('flash_message', 'Category deleted!');
return redirect('backoffice/categories');
}