رفتن به مطلب
انجمن پشتیبانی لاراول ایران

هاست لاراول با پشتیبانی 24 ساعته و امکانات کامل از مدیرهاست

مهدی

کاربر
  • تعداد ارسال ها

    44
  • تاریخ عضویت

  • آخرین بازدید

پست ارسال شده توسط مهدی


  1. با سلام.چطور میشه از پکیج shetabit به درگاه زرین پال متصل شد.من دارم طبق داکیومنتش عمل میکنم منتها ارور اطلاعات ارسال شده ناقص است.
    رو میده.البته داکیومنتش هم خیلی گنگ هست کسی میدونه چجوری میشه اینکار انجام داد؟

    من کدام میزارم اول فایل payment.php:

            'zarinpal' => [
                /* normal api */
                'apiPurchaseUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl',
                'apiPaymentUrl' => 'https://www.zarinpal.com/pg/StartPay/',
                'apiVerificationUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl',
    
                /* sandbox api */
                'sandboxApiPurchaseUrl' => 'https://sandbox.zarinpal.com/pg/services/WebGate/wsdl',
                'sandboxApiPaymentUrl' => 'https://sandbox.zarinpal.com/pg/StartPay/',
                'sandboxApiVerificationUrl' => 'https://sandbox.zarinpal.com/pg/services/WebGate/wsdl',
    
                /* zarinGate api */
                'zaringateApiPurchaseUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl',
                'zaringateApiPaymentUrl' => 'https://www.zarinpal.com/pg/StartPay/:authority/ZarinGate',
                'zaringateApiVerificationUrl' => 'https://ir.zarinpal.com/pg/services/WebGate/wsdl',
    
                'mode' => 'normal', // can be normal, sandbox, zaringate
                'merchantId' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
                'callbackUrl' => 'http://yoursite.com/path/to',
                'description' => 'payment using zarinpal',
            ],

    و کنترلر

    public function Sending_to_zarinpal(Bill $bill){
            $invoice = new Invoice;
            $invoice->amount($bill->price)->via('zarinpal')->transactionId(123);
            $invoice->detail(['detailName' => 'your detail goes here']);
            return Payment::purchase($invoice, function($driver, $transactionId) {
                // Store transactionId in database as we need it to verify payment in the future.
            })->pay()->render();
    
        }

     


  2. با سلام.من یه سایت طراحی کردم.روی لوکال همه چیزش خوب منتها روی هاست که آپلود کردم بغیر پیج اصلی بقیه پیجا رو ارور 

       not found The resource requested could not be found on this server! 404میده.میشه بگین مشکل از کجاست؟


  3. و البته این مسئله که بشه برچسب ها رو به تک تک حساب کرد مثلا اگر عکس اول برچسب فروشگاهی و اداری  وعکس دوم برچسب فروشگاهی و ورزشی داشته باشه تو خروجی فروشگاهی ورزشی اداری تحویل بده یجواریی شبیه تابع distinct


  4. ممنون از پاسختون چيزاي خوبي ازش ياد گرفتم منتها سوال من جواب نداد.سوال من اينکه بشه به برچسب هاي يک عکس خاص که متعلق به يک دسته بندي خاص دسترسي داشت.رابطه ی یک به چند میانی فقط برچسب های یک دسته بندی میده که مد نظر من نیست و از دوبار رابطه یک به چندم نمیشه استفاده کرد چون اول میاد عکس های دسته بندی رو میده واین یک مجموعه است که خاصیت تگ نداره و به ارور میخورم


  5. با سلام.اگه بخوام یه جدول categoriesداشته باشم که هر دسته بندی بتونه چند تا عکس داشته باشه و هر عکس بتونه چند تا برچسب(تگ) داشته باشه باید چطوری این رابطه رو پیاده سازی کنم؟میتونم دوبار HasMany استفاده کنم؟ یا باید از HasManyThrought استفاده کنم؟یا راه دیگه ای داره؟


  6. منظورم از اینکه کار نمیکنه اینکه اگه هزار بارم روی دکمه submit بزنی هیچ ری اکشنی از خودش نشون نمیده و اما اینکه چرا اکشنش دادم به گوگل برای اینکه دیگه بحثی نمونه که روتام اشتباه و وقتی که روی دکمه 

    بزنم قطعا باید به صحفه گوگل بره که هیچ جا نمیره


  7. با سلام.برای ساخت سبد خرید در لاراول یه پکیج هست به اسم Crinsane/LaravelShoppingcart منتها برای لاراول 5.4 هست و از لاراول 7 پشتیبانی نمی کنه آیا کسی پکیجی برای این کار در لاراول 7 میشناسه؟و چجوری با سشن میشه اینکار کرد؟ 


  8. با سلام من دارم به صورت تمرینی  یه سایت فروشگاهی با لاراول درست میکنم.توی یه قسمتش به مشکل خوردم.یه قسمت هست تو صفحه مشاهده محصول که محصولات مرتبط با او محصول میخوامنمایش بدم تو دیتابیس دو تا جدول product وcategory دارم.چطوری  میشه بین اینا رابطه one to many reverse زد؟

    این مشکل حل شد با شرط گذاشتن روی ورودی که از دیتابیس میگیرم


  9. با سلام.سوال اول اینکه آیا متدی هست که مثلا 5 تا بیشترین از یه فیلدیو بگیریم باهاش مثلا اگه یه فیلد بازدید داشته باشیم در دیتابیس 5 تا رکورد پربازدید بهمون بده؟و سوال دوم اینکه فیلدی مثل id که autoincreament وخودش به طور خودکار عدد میده مثلا اگه ما 10 تا رکود داشته باشیم و5 تا آخریو حذف کنیم رکورد بعدی خودکار idش میشه 11 که این نظم شماره ها رو بهم میریزه آیا روشی هست که بعدیش به جای 11 بشه 6؟


  10. با سلام.استاد در ویدیو آموزشی در مورد روش کار با استایل ها و فایل های js توضیح دادند که چیکار کنیم اما در مورد تصاویر چیزی نگفتند.آیا راهی برای تصاویر هست که اونا رو مرتب کنیم یا باید همینطوری اونا رو در پوشه public بزاریم؟ که این خودش خیلی به  هم ریختگی به وجود میاره.


  11. با سلام.میخواستم ایمیل verify بفرستم منتها ارورCannot send message without a sender address میده باتوجه به اینکه من ایمیل به صورت عادی میفرستم و ارور نمیگیره و تنظیمات mail.php هم به صورت زیر تعریف شده

     

     'from' => [
            'address' => env('MAIL_FROM_ADDRESS''mahdiam200@gmail.com'),
            'name' => env('MAIL_FROM_NAME''mahdi developer message'),
        ],

     


  12. این مشکل درست شد منتها یک مسیله ای هست که من اصلا درکش نمی کنم من تو کنترلر خودم مودل article پوشه appیوز  کردم و هیچ استفاده ای از مودل article پوشهfront modelنکردم منتها وقتی مودل articleپوشه frontmodel تغییر میدم دوباره به ارور میخورم کدامو میزارم اگه کسی میتونه توضیح بده533191323_prob9.thumb.png.06ccd8aee309dcbd6402a590cb302c42.png1161602839_prob10.thumb.png.352284b0cf9d5dd1777ef3d68be97748.png1964097698_prob11.thumb.png.cdbb1a32e9c96f9463efc52ea6a92f62.png


  13. درست شد این دو دسته شدن مودلا گیجم کرده بود slugableبه جای اینکه در مودل back استفاده کنم در مودل فرانت استفاده کرده بودم به خاط همین نمی تونست از روی فیلد نام اسلاگ درست کنه.با تشکر از شما که وقت گذاشتید

    • لایک 1

  14. با سلام.در طراحی بخش کاربری بخش نظرات هنگام ذخیره نظر ارور 404 not found میده.نمیدونم مشکل از کجاست فایلها رو در زیر میزارم:

    در ابتدا فایل show.blade.php:

    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link href="{{url('/front/css/main.css')}}" rel="stylesheet">
        <title>Article show</title>
    </head>
    <body dir="rtl">
        <div class="d-flex justify-content-center">
            <div class="row">
                <ul>
                    <li><img src="<?php echo '/storage/photos/1/thumbs/'.basename($article->stimg)?> "></li>
                    <li>name of Article:<a href="{{route('front.Articles.Show',$article->id)}}"><strong>{{$article->name}}</strong></a></li>
                    <li>Date of passage{{$article->created_at}}</li>
                    <li>writer:{{$article->user->name}}</li>
                    <li>This news shown:{{$article->hits}}</li>
                    <li><?php echo strip_tags($article->description);?></li>
                </ul>
                
     
            </div>
          </div>    
          <hr>
          @auth
          <form action='{{route('comment.store', $article->id)}}' method='post'>
            @csrf
          <div class="form-group form-row">
              <div class="form-group col-md-6">
                <label for='name'>نام</label>
                <input type="name" value='{{auth::user()->name}}' class='form-control' readonly>
               </div>
              <div class="form-group col-md-6">
               <label for='email'>ایمیل</label>
                <input type="email" value='{{auth::user()->email}}' class='form-control' name="email" readonly>
              </div>
              <div class="form-group">
               <label for='body'>متن نظر</label>
               <textarea name="body" class='form-control col-md-12' cols="200" rows='5'></textarea>
              </div>
                <input type="submit"  class="btn btn-success form-control" value="ثبت نظر">
              </form>
           <hr>
          @else
          <form action='{{route('comment.store', $article->id)}}' method='post'>
            @csrf
          <div class="form-group form-row">
              <div class="form-group col-md-6">
                <label for='name'>نام</label>
                <input type="name" class='form-control'>
               </div>
              <div class="form-group col-md-6">
               <label for='email'>ایمیل</label>
                <input type="email" class='form-control' name="email">
              </div>
              <div class="form-group">
               <label for='body'>متن نظر</label>
               <textarea name="body" class='form-control col-md-12' cols="200" rows='10'></textarea>
              </div>
                <input type="submit"  class="btn btn-success form-control" value="ثبت نظر">
              </form>
           <hr>
          @endauth
          @foreach ($comments as $comment)
          <div class="row">
          <ul class="col-md-12">
            <li>name:{{$comment->name}}</li>
            <li>email:{{$comment->email}}</li>
            <li>body:{{$comment->body}}<hr></li>
          </ul>
          </div>
              
          @endforeach
     
            
     
          </div>
    </body>
    </html>
     
     و در ادامه فایل web.php:
    <?php
     
    use Illuminate\Support\Facades\Route;
     
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
    ////////////////this is for auth
    Auth::routes();
    //////////////////////////////////////
    Route::get('/f''tstcont@front')->name('front');
    Route::get('/b''tstcont@admin')->name('admin')->middleware('ChekRole');
    Route::get('/''tstcont@welcome')->name('home');
    Route::get('/db''tstcont@db')->name('db');
    Route::get('/schol''tstcont@schol')->name('schol');
    ///////////////////////////////////////////////////////////////category routes
    Route::get('/index''CategoryController@index')->name('index');
    Route::get('/create''CategoryController@create')->name('create');//middleware('auth');
    Route::get('/destroy/{category}''CategoryController@destroy')->name('destroy');
    Route::get('/show/{category}''CategoryController@show')->name('show');
    Route::get('/edit/{category}''CategoryController@edit')->name('edit');
    Route::get('/profile/{category}''tstcont@profile')->name('front.profile');
    //////////////////////////////////////////////////////////////////////
    Route::put('/update/{category}''CategoryController@update')->name('update');
    Route::post('/store''CategoryController@store')->name('store');
    //////////////////////////////////////////////////////////////////////management routes
    route::prefix('admin')->middleware('ChekRole')->group(function(){
        route::get('/edit/{user}','back\AdminController@edit')->name('admin.edit');
        route::get('/status/{user}','back\AdminController@updatestatus')->name('admin.status');
        route::post('/update/{user}','back\AdminController@update')->name('admin.update');
        route::get('/destroy/{user}','back\AdminController@destroy')->name('admin.destroy');
    });
    route::prefix('admin/categories')->middleware('ChekRole')->group(function(){
        route::get('/index','back\CatController@index')->name('admin.categories');
        route::get('/create','back\CatController@create')->name('admin.categories.create');
        route::get('/edit/{cat}','back\CatController@edit')->name('admin.categories.edit');
        route::get('/destroy/{cat}','back\CatController@destroy')->name('admin.categories.destroy');
        route::post('/store','back\CatController@store')->name('admin.categories.store');
        route::put('/update/{cat}','back\CatController@update')->name('admin.categories.update');
    });
    route::prefix('admin/Articles')->middleware('ChekRole')->group(function(){
        route::get('/index','back\ArticleController@index')->name('admin.Articles');
        route::get('/status/{article}','back\ArticleController@updatestatus')->name('admin.Articles.status');
        route::get('/create','back\ArticleController@create')->name('admin.Articles.create');
        route::get('/edit/{article}','back\ArticleController@edit')->name('admin.Articles.edit');
        route::get('/destroy/{article}','back\ArticleController@destroy')->name('admin.Articles.destroy');
        route::post('/store','back\ArticleController@store')->name('admin.Articles.store');
        route::post('/update/{article}','back\ArticleController@update')->name('admin.Articles.update');
    });
    Route::group(['prefix' => 'laravel-filemanager''middleware' => ['web''auth']], function () {
        \UniSharp\LaravelFilemanager\Lfm::routes();
    });
    //////////////////////////////////////////////////for front Articles
    route::prefix('front/Articles')->group(function(){
        route::get('/index','front\ArticleController@index')->name('front.Articles');
        Route::get('/show/{article}''front\ArticleController@show')->name('front.Articles.Show');
    });
    route::prefix('admin/Article/Comments')->middleware('ChekRole')->group(function(){
        route::get('/index','back\CommentController@index')->name('admin.Comments');
        route::get('/status/{comment}','back\CommentController@updatestatus')->name('admin.Comments.status');
        route::get('/edit/{comment}','back\CommentController@edit')->name('admin.Comments.edit');
        route::get('/destroy/{comment}','back\CommentController@destroy')->name('admin.Comments.destroy');
        route::post('/update/{comment}','back\CommentController@update')->name('admin.Comments.update');
    });   
     
    route::post('/Comments/{article}','front\CommentController@store')->name('comment.store');
     
    و فایل  Article.phpکه در پوشه app\frontmodelقرار دارد:
    <?php
     
    namespace App\frontmodel;
    use Cviebrock\EloquentSluggable\Sluggable;
     
    use Illuminate\Database\Eloquent\Model;
     
    class Article extends Model
    {
        use Sluggable;
        protected $fillable=['name','slug','description','user_id','status','stimg'];
     
         public function cats(){
             return $this->belongsToMany(Cat::class);
         }
         public function user(){
             return $this->belongsTo(User::class);
         }
        public function getRouteKeyName()
        {
            return 'slug';
        }
        public function sluggable()
        {
            return [
                'slug' => [
                    'source' => 'name'
                ]
            ];
        }
        public function comments(){
            return $this->hasMany(Comment::class);
        }
    }
    و فایل  Comment.phpکه در پوشه app\frontmodelقرار دارد:
    <?php
     
    namespace App\frontmodel;
     
    use Illuminate\Database\Eloquent\Model;
     
    class Comment extends Model
    {
        protected $fillable=['name','email','body'];
    }
    و در آخر هم CommentControllerکه در پوشه App\Http\Controllers\front قرار دارد:
    <?php
     
    namespace App\Http\Controllers\front;
    use App\frontmodel\Comment;
    use App\frontmodel\Article;
    //use App\Article;
    use App\Http\Controllers\Controller;
     
    use Illuminate\Http\Request;
     
    class CommentController extends Controller
    {
        public function store(Request $request,Article $article)
        {
            $ValidatedData=$request->validate([ 
            'name' => 'required',
            'email' => 'required',
            'body' => 'required'
            ]);
              $article->comments()->create([
                'name'=> $request->name,
                'email'=> $request->email,
                'body'=> $request->body,
              ]);
              
            return redirect('front.Articles.Show');
        }
    }
     

  15. اول اینکه من دارم اینکار برای متد create انجام میدم و هدف ساخت مطلب جدید در نتیجه چیزی از قبل نباید وجود داشته باشه و دوم اینکه توی آموزشم در  کنترلر مقداری دریافت نکرد ولی خطا نداد بلکه خود slugable فیلد slug رو از روی فیلد name پر کرد.


  16. با سلام.طبق ویدیو شماره 31 عمل کردم منتها وقت ذخیره فرم ارور زیر میده:

    Illuminate\Database\QueryException

    SQLSTATE[HY000]: General error: 1364 Field 'slug' doesn't have a default value (SQL: insert into `articles` (`hits`, `name`, `description`, `stimg`, `status`, `user_id`, `updated_at`, `created_at`) values (0, مطلب 1, <p>این محتوایی برای مطلب 1 1است&nbsp;این محتوایی برای مطلب 1 1است</p>, http://localhost/storage/photos/1/Pic 123.jpg, 1, 1, 2020-04-28 12:39:09, 2020-04-28 12:39:09))
     
    و اینم از مدل َََََArticle.phpکه در پوشه frontmodelاست:
    <?php
     
    namespace App\frontmodel;
    use Cviebrock\EloquentSluggable\Sluggable;
     
    use Illuminate\Database\Eloquent\Model;
     
    class Article extends Model
    {
        use Sluggable;
        protected $fillable=['name','description','user_id','status','stimg'];
     
        public function cats(){
            return $this->belongsToMany(Cat::class);
        }
        public function user(){
            return $this->belongsTo(User::class);
        }
        public function getRouteKeyName()
        {
            return 'slug';
        }
        public function sluggable()
        {
            return [
                'slug' => [
                    'source' => 'name'
                ]
            ];
        }
    }
    و اینم از مدل َََََArticle.phpکه در پوشه appاست:
    <?php
     
    namespace App;
     
    use Illuminate\Database\Eloquent\Model;
     
    class Article extends Model
    {
        protected $fillable=['name','description','user_id','status','stimg'];
     
        protected $attributes=[
            'hits'=>"0",
        ];
        public function cats(){
            return $this->belongsToMany(Cat::class);
        }
        public function user(){
            return $this->belongsTo(User::class);
        }
    }
×
×
  • جدید...