@mahdiiranifar228
سلام ببخشید منم همین مشکل رو داشتم ارور نداره ولی delete نمیکنه انگار اصلا نمیره توی تابع destroy . ریدایرکت میشه به همین صفحه index
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ArticleRequest;
use App\Models\Article;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ArticleController extends AdminController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$articles = Article::latest()->paginate(20);
return view('Admin.articles.all', compact('articles'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('Admin.articles.create');
}
/**
* Store a newly created resource in storage.
*
* @param ArticleRequest $request
* @return \Illuminate\Http\Response
*/
public function store(ArticleRequest $request)
{
$imagesUrl = $this->uploadImages($request->file('images'));
auth()->user()->article()->create(array_merge($request->all() , [ 'images' => $imagesUrl]));
return redirect(route('articles.index'));
}
/**
* Display the specified resource.
*
* @param Article $article
* @return \Illuminate\Http\Response
*/
public function show(Article $article)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Article $article
* @return \Illuminate\Http\Response
*/
public function edit(Article $article)
{
return view('Admin.articles.edit' , compact('article'));
}
/**
* Update the specified resource in storage.
*
* @param ArticleRequest $request
* @param Article $article
* @return \Illuminate\Http\Response
*/
public function update(ArticleRequest $request, Article $article)
{
$file = $request->file('images');
$inputs = $request->all();
if($file) {
$inputs['images'] = $this->uploadImages($request->file('images'));
} else {
$inputs['images'] = $article->images;
$inputs['images']['thumb'] = $inputs['imagesThumb'];
}
unset($inputs['imagesThumb']);
$article->update($inputs);
return redirect(route('articles.index'));
}
/**
* Remove the specified resource from storage.
*
* @param ArticleRequest $article
* @return \Illuminate\Http\Response
*/
public function destroy(ArticleRequest $article)
{
$article->delete();
return redirect(route('articles.index'));
}
}
@extends('Admin.master')
@section('content')
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="page-header head-section">
<h2>مقالات</h2>
<a href="{{ route('articles.create') }}" class="btn btn-sm btn-primary">ارساله مقاله</a>
</div>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>عنوان مقاله</th>
<th>تعداد نظرات</th>
<th>مقدار بازدید</th>
<th>تنظیمات</th>
</tr>
</thead>
<tbody>
@foreach($articles as $article)
<tr>
<td><a href="{{ $article->path() }}">{{ $article->title }}</a></td>
<td>{{ $article->commentCount }}</td>
<td>{{ $article->viewCount }}</td>
<td>
<form action="{{ route("articles.destroy" , $article->id) }}" method="post">
{{ method_field('delete') }}
{{ csrf_field() }}
<div class="btn-group btn-group-xs">
<a href="{{ route("articles.edit" , $article->id) }}" class="btn btn-primary">ویرایش</a>
<button type="submit" class="btn btn-danger">حذف</button>
</div>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟